/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.compomics.proteomusicplayer.MS1;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.SourceDataLine;
import sun.audio.AudioData;
import sun.audio.AudioDataStream;
import sun.audio.AudioPlayer;

/**
 *
 * @author Kenneth
 */
public class SpectrumPlayer {

    public static void play(byte[] soundWave, int sampleRate) {
        final AudioFormat af = new AudioFormat(sampleRate, 16, 1, true, true);
        AudioData audiodata = new AudioData(soundWave);
        AudioDataStream audioStream = new AudioDataStream(audiodata);
        AudioPlayer.player.start(audioStream);
    }

    private static void play(SourceDataLine line, byte[] array) {
        line.write(array, 0, array.length);
    }

}
